#pragma once 

#include <iostream>
#include <string>

std::string opers="+-*/%";

enum errornum
{
    DivZero=1,
    ModZero,
    Unknow
};

class Task
{
public:
    Task(int x,int y,char oper)
    :data1_(x)
    ,data2_(y)
    ,oper_(oper)
    ,result_(0)
    ,exitcode_(0)
    {}

    ~Task()
    {}

    void run()
    {
        switch(oper_)
        {
        case '+':
            result_=data1_+data2_;
            break;

        case '-':
            result_=data1_-data2_;
            break;

        case '*':
            result_=data1_*data2_;
            break;

        case '/':
            if(data2_==0)
            {
                exitcode_=DivZero;
            }
            else result_=data1_/data2_;
            break;

        case '%':
            if(data2_==0)
            {
                exitcode_=ModZero;
            }
            else result_=data1_%data2_;
            break;

        default :
            exitcode_=Unknow;
            break;
        }
    }

    void operator()()
    {
        run();
    }

    std::string GetTask()
    {
        std::string ret=to_string(data1_)+oper_+to_string(data2_)+"=?";
        return ret;
    }

    std::string GetResult()
    {
        std::string ret=to_string(data1_)+oper_+to_string(data2_)+'='+to_string(result_)+"[code ="+
        to_string(exitcode_)+"]";
        return ret;
    }

private:
    int data1_;
    int data2_;
    char oper_;

    int result_;
    int exitcode_;
};